package resouce

import (
	"context"

	"go-zero-mall/app/admin/cmd/api/internal/svc"
	"go-zero-mall/app/admin/cmd/api/internal/types"
	"go-zero-mall/app/admin/cmd/rpc/pd"

	"github.com/jinzhu/copier"
	"github.com/zeromicro/go-zero/core/logx"
)

type ResourceCategoryListAllLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewResourceCategoryListAllLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResourceCategoryListAllLogic {
	return &ResourceCategoryListAllLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ResourceCategoryListAllLogic) ResourceCategoryListAll(req *types.ResourceCategoryListAllReq) (resp *types.ResourceCategoryListAllResp, err error) {
	var in pd.UmsResourceListReq
	copier.Copy(&in, req)
	data, err := l.svcCtx.AdminRpc.ResourceCategoryListAll(l.ctx, &in)
	if err != nil {
		return nil, err
	}
	resp = new(types.ResourceCategoryListAllResp)
	copier.Copy(&resp, data)
	return resp, err
}
